//***************************************************************************
//*
//*	File:			dswl_textselection.h
//*	Description:	Wrapper for ITextSelection interface
//*
//***************************************************************************
//*
//*	Note:			This source code is provided "as is" meaning that you may 
//*					use it at your own risk. 
//*					You are free to use it in any way you like.
//*
//***************************************************************************
//*
//*	History:		
//*
//*	-------------------------------------------------------------------------
//*	2003/07/27	|	Initial release									|	rk
//*	-------------------------------------------------------------------------
//*
//***************************************************************************

//
//-------------------------------------------------------------- PREPROCESSOR 
//

#ifndef			_DSWL_TEXTSELECTION_H_INCLUDED
#define			_DSWL_TEXTSELECTION_H_INCLUDED

#if				_MSC_VER > 1000
#pragma once
#ifdef			__SWITCH_SHOW_HEADER
#pragma message ("-- dswl_textselection.h\n")
#endif
#ifdef			__SWITCH_SHOW_HEADER_TREE
#pragma message ("-- "__FILE__"\n")
#endif
#endif 

#ifdef			_DSWL_SWITCH_USE_AUTOCAST
#ifdef			_DSWL_SWITCH_USE_UNSAFE_AUTOCAST
#pragma	message ( "-- dswl_textselection.h \t Warning: Generating auto-cast operator: CITextSelection::operator ITextSelection* () const" )
#else
#pragma	message ( "-- dswl_textselection.h \t Warning: Generating auto-cast operator: CITextSelection::operator       ITextSelection* ()" )
#pragma	message ( "-- dswl_textselection.h \t Warning: Generating auto-cast operator: CITextSelection::operator const ITextSelection* () const" )
#endif
#endif

//
//-------------------------------------------------------------- DEPENDENCIES
//

//
//------------------------------------------------------ FORWARD DECLARATIONS
//

class			CIApplication	;

//
//--------------------------------------------------------- CLASS DECLARATION
//

//***************************************************************************
//**	@DOC		CLASS CITextSelection
//***************************************************************************
//*		@CLASS		Wrapper for ITextSelection interface
//***************************************************************************
class _DSWL_EXT_CLASS CITextSelection  
{
	//																								
	//-----------------------------------------------------------------------						
	//***************************     ATTRIBS     ***************************						
	//-----------------------------------------------------------------------						
	//																								
private:																											// @ACCESS	Private Attributes	
			CComPtr< ITextSelection >	m_pITextSelection	;														// @CMEMBER	Smart pointer to the actual text selection interface
																											
	//																														
	//-----------------------------------------------------------------------												
	//*************************     PROPERTIES     **************************						
	//-----------------------------------------------------------------------												
	//																														
public:																												// @ACCESS	Public Property Methods
			CIApplication		GetApplication		( void )											const	;	// @CMEMBER	Determines the application this selection belongs to
			CITextDocument		GetTextDocument		( void )											const	;	// @CMEMBER	Determines the text document this selection belongs to
			CString				GetText				( void )											const	;	// @CMEMBER	Determines the selection's text
			long				GetCurrentLine		( void )											const	;	// @CMEMBER	Determines the current line's index
			long				GetCurrentColumn	( void )											const	;	// @CMEMBER	Determines the current column's index
			long				GetBottomLine		( void )											const	;	// @CMEMBER	Determines the bottom line's index
			long				GetTopLine			( void )											const	;	// @CMEMBER	Determines the top line's index
																									
			void				SetText				( const CString&				a_strText		)			;	// @CMEMBER	Replaces the selection's text
																									
	//																														
	//-----------------------------------------------------------------------												
	//*************************     INFORMATION     *************************
	//-----------------------------------------------------------------------												
	//																														
public:																												// @ACCESS	Public Information Methods
			BOOL				IsNull				( void )											const	;	// @CMEMBER	Determines whether the internal pointer is <t NULL>
			BOOL				IsValid				( void )											const	;	// @CMEMBER	Determines whether the internal pointer differs from <t NULL>
			BOOL				IsEmpty				( void )											const	;	// @CMEMBER	Determines whether the selection is empty

	//																														
	//-----------------------------------------------------------------------												
	//************************     MODIFICATION     *************************						
	//-----------------------------------------------------------------------												
	//																														
public:																												// @ACCESS	Public Bookmark Methods
			void				SetBookmark			( void )													;	// @CMEMBER	Bookmarks the current line
			BOOL				ClearBookmark		( void )													;	// @CMEMBER	Clears the boomark at the current line
			BOOL				NextBookmark		( void )													;	// @CMEMBER	Jumps to the next bookmark
			BOOL				PreviousBookmark	( void )													;	// @CMEMBER	Jumps to the previous bookmark
public:																												// @ACCESS	Public Selection Methods
			void				Cancel				( void )													;	// @CMEMBER	Cancels the current selection
			void				SelectLine			( void )													;	// @CMEMBER	Selects the current line
			void				SelectAll			( void )													;	// @CMEMBER Selects the whole document
public:																												// @ACCESS	Public Navigation Methods
			void				MoveTo				(		long					a_lLine
													,		long					a_lColumn
													,		BOOL					a_bExtend		)			;	// @CMEMBER	Moves the cursor to the specified line and column while eventually extending the selection
			void				GoToLine			(		long					a_lLine	
													,		BOOL					a_bExtend		)			;	// @CMEMBER	Moves the cursor to the specified line while eventually extending the selection
			void				CharLeft			(		BOOL					a_bExtend		
													,		long					a_lCount		)			;	// @CMEMBER	Moves the cursor the specified number of chars to the left while eventually extending the selection
			void				CharRight			(		BOOL					a_bExtend		
													,		long					a_lCount		)			;	// @CMEMBER	Moves the cursor the specified number of chars to the right while eventually extending the selection
			void				WordLeft			(		BOOL					a_bExtend		
													,		long					a_lCount		)			;	// @CMEMBER	Moves the cursor the specified number of words to the left while eventually extending the selection
			void				WordRight			(		BOOL					a_bExtend		
													,		long					a_lCount		)			;	// @CMEMBER	Moves the cursor the specified number of words to the right while eventually extending the selection
			void				LineUp				(		BOOL					a_bExtend		
													,		long					a_lCount		)			;	// @CMEMBER	Moves the cursor the specified number of lines upwards while eventually extending the selection
			void				LineDown			(		BOOL					a_bExtend		
													,		long					a_lCount		)			;	// @CMEMBER	Moves the cursor the specified number of lines downwards while eventually extending the selection
			void				PageUp				(		BOOL					a_bExtend		
													,		long					a_lCount		)			;	// @CMEMBER	Moves the cursor the specified number of pages upwards while eventually extending the selection
			void				PageDown			(		BOOL					a_bExtend		
													,		long					a_lCount		)			;	// @CMEMBER	Moves the cursor the specified number of pages downwards while eventually extending the selection
			void				StartOfLine			(		DsStartOfLineOptions	a_enuOptions	
													,		BOOL					a_bExtend		)			;	// @CMEMBER	Moves the cursor to the end of the line while eventually extending the selection
			void				EndOfLine			( 		BOOL					a_bExtend		)			;	// @CMEMBER	Moves the cursor to the end of the line while eventually extending the selection
			void				StartOfDocument		( 		BOOL					a_bExtend		)			;	// @CMEMBER	Moves the cursor to the top of the document while eventually extending the selection
			void				EndOfDocument		( 		BOOL					a_bExtend		)			;	// @CMEMBER	Moves the cursor to the end of the document while eventually extending the selection
public:																												// @ACCESS	Public Insertion Methods
			void				NewLine				( void )													;	// @CMEMBER	Inserts a new line at the current position
			void				DestructiveInsert	( const CString&				a_strText		)			;	// @CMEMBER	Inserts the specified text at the current position in overwrite mode
public:																												// @ACCESS	Public Deletion Methods
			void				Backspace			(		long					a_lCount		)			;	// @CMEMBER	Simulates pressing the <BACKSPACE> key the specified number of times
			void				Delete				(		long					a_lCount		)			;	// @CMEMBER	Simulates pressing the <DEL> key the specified number of times
			void				DeleteWhitespace	(		DsWhitespaceOptions		a_enuDir		)			;	// @CMEMBER Deletes all whitespaces in the specified direction
public:																												// @ACCESS	Public Clipboard Methods
			void				Copy				( void )													;	// @CMEMBER	Copies the selection to the clipboard
			void				Cut					( void )													;	// @CMEMBER Copies the selection to the clipboard and deletes it
			void				Paste				( void )													;	// @CMEMBER	Pastes the clipboard content at the current position
public:																												// @ACCESS	Public Extended Manipulation Methods
			void				ChangeCase			(		DsCaseOptions			a_enuType		)			;	// @CMEMBER	Changes the selection's case
			void				Tabify				( void )													;	// @CMEMBER	Tabifies the selection
			void				Untabify			( void )													;	// @CMEMBER	Un-Tabifies the selection
			void				Indent				( void )													;	// @CMEMBER	Indents the selection
			void				Unindent			( void )													;	// @CMEMBER	Un-Indents the selection
			void				SmartFormat			( void )													;	// @CMEMBER	Smart-Formats the selection
public:																												// @ACCESS	Public Search and Replace Methods
			BOOL				FindText			( const	CString&				a_strFind
													,		DWORD					a_dwFlags		)			;	// @CMEMBER	Finds (and marks) the next occurance of the specified text
			BOOL				ReplaceText			( const	CString&				a_strFind
													, const	CString&				a_strReplace
													,		DWORD					a_dwFlags		)			;	// @CMEMBER	Replaces all occurances of the specified text with the specified replace string

	//																												
	//-----------------------------------------------------------------------										
	//**************************     OPERATORS     **************************										
	//-----------------------------------------------------------------------										
	//																												
public:																												// @ACCESS	Public Operators
			bool				operator	==		( const CITextSelection&		a_Other			)	const	;	// @CMEMBER	Comparison operator
			bool				operator	!=		( const CITextSelection&		a_Other			)	const	;	// @CMEMBER	Comparison operator
			bool				operator	<=		( const CITextSelection&		a_Other			)	const	;	// @CMEMBER	Comparison operator
			bool				operator	>=		( const CITextSelection&		a_Other			)	const	;	// @CMEMBER	Comparison operator
			bool				operator	<		( const CITextSelection&		a_Other			)	const	;	// @CMEMBER	Comparison operator
			bool				operator	>		( const CITextSelection&		a_Other			)	const	;	// @CMEMBER	Comparison operator
																									
			CITextSelection&	operator	=		(		ITextSelection*			a_pIOther		)			;	// @CMEMBER	Copy operator
																									
			ITextSelection*		operator	*		( void )													;	// @CMEMBER	Dereference operator
	const	ITextSelection*		operator	*		( void )											const	;	// @CMEMBER	Dereference operator
																									
			ITextSelection*		operator	->		( void )													;	// @CMEMBER	Member access operator
	const	ITextSelection*		operator	->		( void )											const	;	// @CMEMBER	Member access operator
																									
	#ifdef	_DSWL_SWITCH_USE_AUTOCAST
	#ifdef	_DSWL_SWITCH_USE_UNSAFE_AUTOCAST
								operator			ITextSelection*	( void )							const	;	// @CMEMBER	TypeCast operator
	#else
								operator			ITextSelection*	( void )									;	// @CMEMBER	TypeCast operator
								operator	const	ITextSelection*	( void )							const	;	// @CMEMBER	TypeCast operator
	#endif
	#endif

	//																						
	//-----------------------------------------------------------------------				
	//***********************     CON/DESTRUCTION     ***********************				
	//-----------------------------------------------------------------------				
	//																						
public:																												// @ACCESS	Public Con-/Destruction Methods	
			 CITextSelection( ITextSelection* a_pITextSelection = NULL );											// @CMEMBER	Default constructor
	virtual ~CITextSelection();																						// @CMEMBER	Default destructor
};																													
//***************************************************************************
//**	@END
//***************************************************************************

#endif		// _DSWL_TEXTSELECTION_H_INCLUDED
